﻿using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MikroMagazaObject
{
    public partial class frmSiemensGonderim : XtraForm
    {
        SiemensPos islem = new SiemensPos();
        string kdvSiralamasi = "";

        public frmSiemensGonderim(string cnnString, string fileLocation, string depo,string kdvsira)
        {
            InitializeComponent();
            islem.CnnString = cnnString;
            islem.FileLocation = fileLocation;
            islem.DepoID = depo;
            kdvSiralamasi = kdvsira;
        }

        private void Button1_Click(object sender, EventArgs e)
        {
            if (Rd_Tum.Checked)
            {
                islem.SqlCommand = "SELECT * FROM Q_SiemensAktarim";
                islem.Tarih = new DateTime(1900, 1, 1);
            }
            else if (RadioButton2.Checked)
            {
                islem.SqlCommand = "SELECT * FROM Q_SiemensAktarim";
                islem.Tarih = new DateTime(Dte_Start.Value.Year, Dte_Start.Value.Month, Dte_Start.Value.Day, 0, 0, 0);
            }
            else if (RadioButton1.Checked)
            {
                islem.SqlCommand = "SELECT * FROM Q_SiemensAktarim2";
            }


            bool ilk = true;
            foreach (int item in islem.StokDosyasiOlustur(kdvSiralamasi))
            {
                if (ilk)
                {
                    Label1.Text = "Aktarıma Başlandı !";
                    Prg_Status.Minimum = 0;
                    Prg_Status.Maximum = item * 2;
                    ilk = false;
                }
                else
                {
                    Prg_Status.Value = item;
                }

                Prg_Status.Refresh();
                Application.DoEvents();
            }
            Label1.Text = "Aktarım Tamamlandı !";
            Prg_Status.Value = Prg_Status.Maximum;
        }
    }
}
